package oop.ex3.nameserver.actions;

import java.io.IOException;

import oop.ex3.messages.MessageInterface;
import oop.ex3.messages.SimpleMessage;
import oop.ex3.messages.ValidHeaders;
import oop.ex3.messages.exception.InvalidHeaderException;
import oop.ex3.nameserver.NSContext;
import oop.ex3.sockets.ClientSocket;

public abstract class NsAction {
	
	protected NSContext _context;
	
	public NsAction(NSContext context){
		_context = context;
	}
	
	public abstract boolean run(ClientSocket socket, MessageInterface msg);
	
	public static boolean sendDone(ClientSocket s){
		try {
			s.SendMessage(new SimpleMessage(ValidHeaders.DONE));
		} catch (IOException e) {
			return false;
		} catch (InvalidHeaderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return true;
	}
	

}
